package com.saile.controller.web.pioneer;

import com.saile.controller.base.BaseController;
import com.saile.domain.Advert;
import com.saile.domain.Media;
import com.saile.domain.MessageBoard;
import com.saile.domain.News;
import com.saile.service.AdvertService;
import com.saile.service.MediaService;
import com.saile.service.MessageBoardService;
import com.saile.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by lutao on 2017/7/14.
 * 先锋号controller
 */
@RequestMapping("/pioneer")
@Controller
public class PioneerController extends BaseController {
    @Autowired
    AdvertService advertService;
    @Autowired
    NewsService newsService;
    @Autowired
    MediaService mediaService;
    @Autowired
    MessageBoardService messageBoardService;

    /**
     * 先锋号首页
     *
     * @return
     */
    @RequestMapping(value = "/index")
    public ModelAndView index() {
        super.getCookie();
        ModelAndView mov = new ModelAndView();
        mov.setViewName("/web/pioneer/index");
        Map<String, String> map = new HashMap<>();
//获取bnner
        map.put("locationId", String.valueOf(Advert.LOCATIONID_BANNER));
        List<Advert> advertBannerList = advertService.getAdvertList(map);
        mov.addObject("advertBannerList", advertBannerList);
        map.clear();
        //获取bnner右边
        map.put("locationId", String.valueOf(Advert.LOCATIONID_BANNER_RIGHT));
        List<Advert> advertBannerRightList = advertService.getAdvertList(map);
        mov.addObject("advertBannerRightList", advertBannerRightList);
        map.clear();


        //红领巾动态
        map.put("locationId", String.valueOf(Advert.LOCATIONID_RED_SCARF_DYNAMIC));
        List<Advert> redSscarfDynamic = advertService.getAdvertList(map);
        mov.addObject("redSscarfDynamic", redSscarfDynamic);
        map.clear();
       //红领巾知识
        map.put("locationId", String.valueOf(Advert.LOCATIONID_RED_SCARF_KNOWLEDGE));
        List<Advert> redSscarfKnowledge = advertService.getAdvertList(map);
        mov.addObject("redSscarfKnowledge", redSscarfKnowledge);
        map.clear();
       //五彩校园
        map.put("locationId", String.valueOf(Advert.LOCATIONID_COLORFUL_SHCOOL));
        List<Advert> colorfulShcool = advertService.getAdvertList(map);
        mov.addObject("colorfulShcool", colorfulShcool);
        map.clear();

        map.put("newsType", String.valueOf(News.NEW_TYPE_RED_SCARF_DYNAMIC));
        List<News> news_1List = newsService.getNewsList(map);
        mov.addObject("news_1List", news_1List);
        map.clear();

        // 智慧队课
        map.put("locationId", String.valueOf(Advert.LOCATIONID_TEAM_WISDOM_LESSONS));
        List<Advert> teamWisdomLessons = advertService.getAdvertList(map);
        mov.addObject("teamWisdomLessons", teamWisdomLessons);
        map.clear();


        map.put("columnType", String.valueOf(Media.COLUMN_TYPE_RED_SCARF_TV_STATION));
        map.put("mediaType", String.valueOf(Media.MEDIA_TYPE_VOICE));
        map.put("length", String.valueOf(12));
        List<Media> media_2List = mediaService.getMediaList(map);
        mov.addObject("media_2List", media_2List);
        map.clear();
/**
 * 红领巾小提案
 */
        map.put("type", String.valueOf(MessageBoard.TYPE_RED_SCARF_SMALL_PROPOSAL));
        map.put("maxLength", "5"); map.put("status", String.valueOf(MessageBoard.STATUS_VALID));

        List<MessageBoard> messageBoardList = messageBoardService.getMessageBoardList(map);
        mov.addObject("messageBoardList", messageBoardList);
        map.clear();

        return mov;
    }

    /**
     * 先锋号头部
     *
     * @return
     */
    @RequestMapping(value = "/head")
    public ModelAndView head() {
        // source: 1(来源于网站) | 2(来源于微站)
        ModelAndView mov = new ModelAndView();
        mov.setViewName("/web/pioneer/head");

        return mov;
    }/**
     * 先锋号头部
     *
     * @return
     */
    @RequestMapping(value = "/foot")
    public ModelAndView foot() {
        // source: 1(来源于网站) | 2(来源于微站)
        ModelAndView mov = new ModelAndView();
        mov.setViewName("/web/pioneer/foot");

        return mov;
    }

}
